//
//  SAShowPhotoVC.m
//  yidiantong
//
//  Created by 黄志刚 on 2020/12/3.
//

#import "SAShowPhotoVC.h"
#import "YBImageBrowser.h"
#import <SDWebImage/UIImageView+WebCache.h>

@interface SAShowPhotoVC ()<YBImageBrowserDataSource>

@property (nonatomic, strong) NSArray *imageList;

@end

@implementation SAShowPhotoVC

-(instancetype)initWithImageList:(NSArray *)imageList {
    if (self = [super init]) {
        self.imageList = imageList;
    }
    return self;
}


- (void)viewDidLoad {
    [super viewDidLoad];
    [self initUI];
}

-(void)initUI{
    
    YBImageBrowser *browser = [YBImageBrowser new];
    browser.dataSourceArray = self.imageList;
    browser.dataSource = self;
    browser.currentPage = 0;
    [browser show];
}

//YBImageBrowserDataSource 代理实现赋值数据
- (NSInteger)yb_numberOfCellsInImageBrowser:(YBImageBrowser *)imageBrowser {
    return self.imageList.count;
}

- (id<YBIBDataProtocol>)yb_imageBrowser:(YBImageBrowser *)imageBrowser dataForCellAtIndex:(NSInteger)index {
    NSString *urlStr = [self.imageList objectAtIndex:index];
    YBIBImageData *data = [YBIBImageData new];
    data.imageURL = [NSURL URLWithString:urlStr];
    return data;
}

@end

